//
//  HRZOrderGoodsDetailCell.m
//  EMarket
//
//  Created by 石头 on 2018/9/6.
//  Copyright © 2018 好日子. All rights reserved.
//

#import "HRZOrderGoodsDetailCell.h"
// Controllers

// Models
#import "HRZOrderGoodsDetailModel.h"
// Views

// Vendors

// Categories
#import <UIImageView+WebCache.h>
// Others


@interface HRZOrderGoodsDetailCell ()
@property (strong, nonatomic) UIImageView *mImageV;
@property (strong, nonatomic) UILabel *mTitle;
@property (strong, nonatomic) UILabel *mPrice;
@property (strong, nonatomic) UILabel *mCount;

@end

@implementation HRZOrderGoodsDetailCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self addSubview:self.mImageV];
        [self addSubview:self.mTitle];
        [self addSubview:self.mPrice];
        [self addSubview:self.mCount];
        
        self.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return self;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (void)layoutSubviews {
    //  image location
    [self.mImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self);
        make.height.mas_equalTo(self.height - 20);
        make.left.mas_equalTo(self.left + 20);
        make.width.mas_equalTo(self.height -  20).multipliedBy(1.0);
//        make.width.mas_equalTo(make.height);
    }];
    
    //  title location
    [self.mTitle mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mImageV.mas_top);
        make.left.mas_equalTo(self.mImageV.mas_right).mas_offset(10);
    }];
    
    // price location
    [self.mPrice mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mImageV.mas_top);
        make.right.mas_equalTo(self.mas_right).mas_offset(-20);
    }];
    
    // count location
    [self.mCount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.mPrice.mas_bottom).mas_offset(5);
        make.right.mas_equalTo(self.mPrice.mas_right);
    }];
}
#pragma mark - ----  Getter/Setter  ----
- (void)setModel:(HRZOrderGoodsDetailModel *)model {
    _model = model;
    _mTitle.text = _model.goodsName;
    _mPrice.text = _model.goodsPrice;
    _mCount.text = _model.goodsNumber;
    [_mImageV sd_setImageWithURL:URLString(_model.goodsImg) placeholderImage:PLACEHOLDERIMAGE];
}

- (UIImageView *)mImageV{
    if (!_mImageV) {
        _mImageV = [[UIImageView alloc] init];
        _mImageV.contentMode = UIViewContentModeScaleAspectFit;
        
    }
    return _mImageV;
}

- (UILabel *)mTitle{
    if (!_mTitle) {
        _mTitle = [[UILabel alloc] init];
        _mTitle.font = PFR15Font;
    }
    return _mTitle;
}

- (UILabel *)mPrice{
    if (!_mPrice) {
        _mPrice = [[UILabel alloc] init];
        _mPrice.font = PFR13Font;
    }
    return _mPrice;
}

- (UILabel *)mCount{
    if (!_mCount) {
        _mCount = [[UILabel alloc] init];
        _mCount.font = PFR10Font;
    }
    return _mCount;
}


@end
